# Create a Java bot

To create a Java bot, follow the steps below:

Step 1: Create a new Java project using any IDE (IntelliJ has been used in this document)

Java1

Step 2: Provide the location for the project and fill other fields as well and click on Finish button

Java2

A new project will be created and you will able to see the project structure in IDE.

Java3

Step 3: Add Tulip libraries to the project

Create a new directory and add the library jar in that folder. Here “libs” folder is created under the parent folder

Java4 Java5

Add the dependency in the module:

File -> Project Structure -> Modules -> Dependencies and click on Add. Then select the jars that are present in libs folder. Click on OK button

Java6

Step 4: Add the library dependencies in bundle.gradle file by including a line

        compile fileTree(dir: 'libs', include; ['*.jar'])"
Java7

Step 5: Create a new java class under srv->main->java and add the business logic

Java8

A new class will be created as shown below:

Java9

Click on the Grade logo to load the imported library dependencies. You will be able to see Build Successful message as shown in the screenshot below:

Java10

Import needed library class to the main class as shown below:

Java11

Then extend the JavaBotTemplate to the class and implementation for the abstract method “botLogic”. Add the business logic inside botLogic method.

Java12

Above bot will send reply as “Hello world”.

Methods available in JavaBotTemplate:

        success : sends the message passed in the argument with message type “success”
        failure: sends the message passed in the argument with message type “failed”
        addVariable: add the object to bot state which shall later to passed to Tulip